//
//  ChooseDoctorModel.m
//  QuickCure1
//
//  Created by apple on 2016/10/31.
//  Copyright © 2016年 maoge. All rights reserved.
//

#import "ChooseDoctorModel.h"
#import <AFNetworking.h>
#import "NetWorkTool.h"
#import <YYModel.h>

@implementation ChooseDoctorModel


- (NSString *)description{
    
    return [self yy_modelDescription];
}

//- (void)encodeWithCoder:(NSCoder *)aCoder{
//    
//    [aCoder encodeObject:self.doctor_gender forKey:@"doctor_gender"];
//    [aCoder encodeObject:self.doctor_id forKey:@"doctor_id"];
//    [aCoder encodeObject:self.doctor_gender forKey:@"doctor_gender"];
//    [aCoder encodeObject:self.doctor_gender forKey:@"doctor_gender"];
//    [aCoder encodeObject:self.doctor_gender forKey:@"doctor_gender"];
//    [aCoder encodeObject:self.doctor_gender forKey:@"doctor_gender"];
//    [aCoder encodeObject:self.doctor_gender forKey:@"doctor_gender"];
//    [aCoder encodeObject:self.doctor_gender forKey:@"doctor_gender"];
//    [aCoder encodeObject:self.doctor_gender forKey:@"doctor_gender"];
//    [aCoder encodeObject:self.doctor_gender forKey:@"doctor_gender"];
//    [aCoder encodeObject:self.doctor_gender forKey:@"doctor_gender"];
//    [aCoder encodeObject:self.doctor_gender forKey:@"doctor_gender"];
//    [aCoder encodeObject:self.doctor_gender forKey:@"doctor_gender"];
//    
//}

- (void)encodeWithCoder:(NSCoder *)aCoder{
    unsigned int count = 0;
    Ivar *ivars = class_copyIvarList([self class], &count);
    for (int i = 0; i < count; i++) {
        Ivar ivar = ivars[i];
        const char *name = ivar_getName(ivar);
        NSString *key = [NSString stringWithUTF8String:name];
        id value = [self valueForKey:key];
        [aCoder encodeObject:value forKey:key];
    }
    free(ivars);
}
//取
- (instancetype)initWithCoder:(NSCoder *)aDecoder{
    if (self = [super init]) {
        unsigned int count = 0;
        Ivar *ivars = class_copyIvarList([self class], &count);
        for (int i = 0; i < count; i++) {
            Ivar ivar = ivars[i];
            const char *name = ivar_getName(ivar);
            NSString *key = [NSString stringWithUTF8String:name];
            id value = [aDecoder decodeObjectForKey:key];
            [self setValue:value forKey:key];
        }
        free(ivars);
    }
    return self;
}



#pragma mark
#pragma mark - 加载网络数据转化成模型数组

+ (void)getModelList7WithComplete:(void(^)(NSArray<ChooseDoctorModel *> *modelList,NSError *error))completeBlock{
    
//    七号借口
    NSString *urlString = kMatchDoctors;
    NSDictionary *paramDic = @{@"ci1_id":@1,
                               @"ci2_id":@3,
                               @"ci3_id":@3,
                               @"diagnosis_type":@0,
                               @"page_size":@15,
                               @"is_confirmed":@1,
                               @"user_id":@1000089,
                               @"page":@1,
                               @"has_diagnosis":@2
                               };
    
    
    [[NetWorkTool shareManager] POST_RequestWithUrlString:urlString parmas:paramDic successBloock:^(NSDictionary * responseObject) {
        NSArray *arr =responseObject[@"data"];
        NSArray<ChooseDoctorModel *> *modelList = [NSArray yy_modelArrayWithClass:[ChooseDoctorModel class] json:arr];
        completeBlock(modelList,nil);
//        NSLog(@"responseObject = %@",responseObject);
    } failureBlock:^(NSError *error) {
        completeBlock(nil,error);
        NSLog(@"error = %@",error);
    }];

}

////    13号借口
//    NSString *urlString = kDoctorListUrl;
//    NSDictionary *paramDic = @{
//                               @"user_id":@"1000089",
//                               @"page_size":@15,
//                               @"page":@1
//                               };

+ (void)getModelList13WithComplete:(void(^)(NSArray<ChooseDoctorModel *> *modelList,NSError *error))completeBlock{
    
    //    13号借口
    NSString *urlString = kDoctorListUrl;
    NSDictionary *paramDic = @{
                               @"user_id":@"1000089",
                               @"page_size":@15,
                               @"page":@1
                               };
    
    [[NetWorkTool shareManager] POST_RequestWithUrlString:urlString parmas:paramDic successBloock:^(NSDictionary * responseObject) {
        NSArray *arr =responseObject[@"data"];
        NSArray<ChooseDoctorModel *> *modelList = [NSArray yy_modelArrayWithClass:[ChooseDoctorModel class] json:arr];
        completeBlock(modelList,nil);
//        NSLog(@"responseObject = %@",responseObject);
    } failureBlock:^(NSError *error) {
        completeBlock(nil,error);
        NSLog(@"error = %@",error);
    }];
    
}



@end
